package com.t9;

/**
 * Created by xuyiwei on 2018/7/21.
 */
interface game{
    void play();
}
interface gameFactory{
    game getGame();
}
class coin implements game{

    @Override
    public void play() {
        System.out.println("抛硬币游戏");
    }
}

class shaizi implements game{

    @Override
    public void play() {
        System.out.println("筛子游戏");
    }
}

class coinFactory implements gameFactory{

    @Override
    public game getGame() {
        return new coin();
    }
}

class shaiziFactory implements gameFactory{

    @Override
    public game getGame() {
        return new shaizi();
    }
}
public class e19 {
    public static void playType(gameFactory factory){
        game g = factory.getGame();
        g.play();
    }

    public static void main(String[] args) {
        playType(new coinFactory());
        playType(new shaiziFactory());
    }
}
